<?php

namespace App\Providers;

use App\Http\Service\member\MemberService;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider {

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register() {
        //
        $this->app->bind('MemberService', function () {
            return new MemberService();
        });
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot() {
        //

        \Illuminate\Support\Facades\DB::listen(function($query) {
            $tmp = str_replace('?', '"' . '%s' . '"', $query->sql);
            $tmp = vsprintf($tmp, $query->bindings);
            $tmp = str_replace("\\", "", $tmp);
            //\Log::info(' execution time: ' . $query->time . 'ms; ' . $tmp . "\n\n\t");
            \Log::channel('sqlLog')->info('execution time: ' . $query->time . 'ms; ' . $tmp . "\n\n\t");
        });
    }

}
